{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-09-18T11:20:03.795068Z",
     "start_time": "2025-09-18T11:19:56.702019Z"
    }
   },
   "source": [
    "def fib(n):\n",
    "    if n == 0:\n",
    "        return 0\n",
    "    elif n == 1:\n",
    "        return 1\n",
    "    else:\n",
    "        return fib(n-1) + fib(n -2)\n",
    "\n",
    "def fib_seq(n):\n",
    "    res = []\n",
    "    if n > 0:\n",
    "        res.extend(fib_seq(n-1))\n",
    "    res.append(fib(n))\n",
    "    return res\n",
    "\n",
    "fib_seq(30)"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "> \u001B[32mc:\\users\\administrator\\appdata\\local\\temp\\ipykernel_16120\\1423579957.py\u001B[39m(\u001B[92m7\u001B[39m)\u001B[36m<module>\u001B[39m\u001B[34m()\u001B[39m\n",
      "\n",
      "5\n",
      "5\n",
      "5\n",
      "5\n",
      "5\n",
      "--KeyboardInterrupt--\n",
      "\n",
      "KeyboardInterrupt: Interrupted by user\n",
      "enter func()\n",
      "6\n"
     ]
    }
   ],
   "execution_count": 4
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
